﻿using CoreShop.Library;
using CoreShop.Model;
using SqlSugar.Extensions;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using static CoreShop.Library.GlobalEnumVars;

namespace CoreShop.App
{
    public partial class UIDishPinterSetupItem : UIUserControl
    {
        public UIDishPinterSetupItem()
        {
            InitializeComponent();
        }

        public corecmsprintscheme Info { get; set; }
        public UIDishPinterSetupItem(corecmsprintscheme info)
        {
            InitializeComponent();
            Info = info;
            uiCheckBox1.Checked = info.Selected;            
        }

        public UIButton CreateButton(string text)
        {
            UIButton btn = new UIButton();
            btn.BackColor = System.Drawing.Color.White;
            btn.Cursor = System.Windows.Forms.Cursors.Hand;
            btn.FillColor = System.Drawing.Color.White;
            btn.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
            btn.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(175)))), ((int)(((byte)(83)))));
            btn.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
            btn.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(248)))), ((int)(((byte)(229)))));
            btn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            btn.ForeColor = System.Drawing.Color.Black;
            btn.ForeHoverColor = System.Drawing.Color.Black;
            btn.ForePressColor = System.Drawing.Color.Black;
            btn.ForeSelectedColor = System.Drawing.Color.Black;
            btn.MinimumSize = new System.Drawing.Size(1, 1);
            btn.Name = text;
            btn.Radius = 9;
            btn.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            btn.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(175)))), ((int)(((byte)(83)))));
            btn.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(176)))), ((int)(((byte)(124)))), ((int)(((byte)(32)))));
            btn.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(189)))), ((int)(((byte)(0)))));
            btn.Size = new System.Drawing.Size(58, 25);
            btn.Style = Sunny.UI.UIStyle.Custom;
            btn.StyleCustomMode = true;
            btn.Text = text;
            btn.Parent = this;
            return btn;
        }

        private void UIFDishPinterSetupItem_Paint(object sender, PaintEventArgs e)
        {
            if (Info == null) return;
            using (Font font = new System.Drawing.Font("微软雅黑", 10.5F))
            {
                e.Graphics.DrawString(Info.printerName, font, Color.Black, new Rectangle(125, 0, Width, Height), ContentAlignment.MiddleLeft);
                e.Graphics.DrawString(Info.region, font, Color.Black, new Rectangle(270, 0, Width, Height), ContentAlignment.MiddleLeft);
                e.Graphics.DrawString(Info.gearName, font, Color.Black, new Rectangle(410, 0, Width, Height), ContentAlignment.MiddleLeft);
                //e.Graphics.DrawString(EnumHelper.GetEnumByValue<GlobalEnumVars.printerType>(Info.printerType.ObjToInt(0)), font, Color.Black, new Rectangle(550, 0, 119, Height), ContentAlignment.MiddleCenter);
                //e.Graphics.DrawString(EnumHelper.GetEnumByValue<GlobalEnumVars.BrandType>(Info.brandId.ObjToInt(0)), font, Color.Black, new Rectangle(685, 0, 119, Height), ContentAlignment.MiddleCenter);
            }
        }

        public event EventHandler CheckBoxChecked;
        private void uiCheckBox1_CheckedChanged(object sender, System.EventArgs e)
        {
            if (Info != null) Info.Selected = uiCheckBox1.Checked;
            CheckBoxChecked?.Invoke(Info, e);
        }

        public bool Checked
        {
            get => uiCheckBox1.Checked;
            set => uiCheckBox1.Checked = value;
        }
    }
}
